<template>
	<view>
		<van-search :value="searchKey" input-align="center" placeholder="请输入搜索关键词" />
		<uni-swiper-dot class="uni-swiper-dot-box" @clickItem=clickItem :info="info" :current="current" :mode="mode"
			:dots-styles="dotsStyles" field="content">
			<swiper class="swiper-box" @change="change" :current="swiperDotIndex">
				<swiper-item v-for="(item, index) in 3" :key="index">
					<view class="swiper-item" :class="'swiper-item' + index">
						<text style="color: #fff; font-size: 32px;">{{index+1}}</text>
					</view>
				</swiper-item>
			</swiper>
		</uni-swiper-dot>
		<van-tabs animated color='#2979ff'>
			<van-tab title="课程" name="course">
				<ul class="store-body">
					<li v-for="(item,index) in 12" :key="index" class="book-div">
						<img src="/static/image/logo.png" class="book-img" />
						<view class="book-name">
							<text>三国演义</text>
						</view>
					</li>
				</ul>
			</van-tab>
			<!-- <van-tab title="文献" name="literature">
				<ul class="store-body">
					<li v-for="(item,index) in 10" :key="index" class="book-div">
						<img src="/static/image/logo.png" class="book-img" />
						<view class="book-name">
							<text>红楼梦</text>
						</view>
					</li>
				</ul>
			</van-tab> -->
			<van-tab title="名著" name="masterpiece">
				<ul class="store-body">
					<li v-for="(item,index) in 12" :key="index" class="book-div">
						<img src="/static/image/logo.png" class="book-img" />
						<view class="book-name">
							<text>西游记</text>
						</view>
					</li>
				</ul>
			</van-tab>
		</van-tabs>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchKey: '',
				info: [{
						colorClass: 'uni-bg-red',
						url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
						content: '内容 A'
					},
					{
						colorClass: 'uni-bg-green',
						url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
						content: '内容 B'
					},
					{
						colorClass: 'uni-bg-blue',
						url: 'https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
						content: '内容 C'
					}
				],
				dotStyle: [{
						backgroundColor: 'rgba(0, 0, 0, .3)',
						border: '1px rgba(0, 0, 0, .3) solid',
						color: '#fff',
						selectedBackgroundColor: 'rgba(0, 0, 0, .9)',
						selectedBorder: '1px rgba(0, 0, 0, .9) solid'
					},
					{
						backgroundColor: 'rgba(255, 90, 95,0.3)',
						border: '1px rgba(255, 90, 95,0.3) solid',
						color: '#fff',
						selectedBackgroundColor: 'rgba(255, 90, 95,0.9)',
						selectedBorder: '1px rgba(255, 90, 95,0.9) solid'
					},
					{
						backgroundColor: 'rgba(83, 200, 249,0.3)',
						border: '1px rgba(83, 200, 249,0.3) solid',
						color: '#fff',
						selectedBackgroundColor: 'rgba(83, 200, 249,0.9)',
						selectedBorder: '1px rgba(83, 200, 249,0.9) solid'
					}
				],
				modeIndex: -1,
				styleIndex: -1,
				current: 0,
				mode: 'default',
				dotsStyles: {},
				swiperDotIndex: 0
			}
		},
		methods: {
			clickItem(e) {
				this.swiperDotIndex = e
			},
			change(e) {
				this.current = e.detail.current
			},
		},
		onLoad(){
			this.$Api.getBooks(1).catch(res=>{
				console.log(res);
			})
		}
	}
</script>

<style>
	.store-body {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
		justify-content: space-around;
	}

	.book-div {
		width: 100px;
		height: 130px;
		background-color: #fff;
		margin: 5px 0px;
		display: flex;
		flex-direction: column;
		align-items: center;
		border-radius: 10px;
	}

	.book-img {
		width: 80%;
		height: 70%;
		margin-top: 5px;
	}

	.book-name {
		width: 100%;
		text-align: center;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			margin: 0 auto;
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}

	.swiper-box {
		height: 200px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 200px;
		color: #fff;
	}

	.swiper-item0 {
		background-color: #cee1fd;
	}

	.swiper-item1 {
		background-color: #b2cef7;
	}

	.swiper-item2 {
		background-color: #cee1fd;
	}
</style>